package br.ufrj.dcc.tp.ns.types;

import java.math.BigDecimal;

/***
 * Essa classes representa um evento que ocorreu na topologia.
 * E.g: Queda de enlace ou Recuperação de enlace
 * @author wakim
 *
 */
public class NsTracingEvent extends NsTracingElement implements Comparable<NsTracingEvent>{
	
	private LinkEventType type;
	private int source, destination;
	private BigDecimal time;

	public LinkEventType getType() {
		return type;
	}

	public NsTracingEvent setType(LinkEventType type) {
		this.type = type;
		return this;
	}

	public int getSource() {
		return source;
	}

	public NsTracingEvent setSource(int source) {
		this.source = source;
		return this;
	}

	public int getDestination() {
		return destination;
	}

	public NsTracingEvent setDestination(int destination) {
		this.destination = destination;
		return this;
	}

	public BigDecimal getTime() {
		return time;
	}

	public NsTracingEvent setTime(BigDecimal time) {
		this.time = time;
		return this;
	}
	
	@Override
	public boolean equals(Object o) {
		if(o instanceof NsTracingEvent) {
			NsTracingEvent other = (NsTracingEvent) o;
			return	other.getType() == type &&
					(source == other.getSource() && destination == other.getDestination()) ||
					(source == other.getDestination() && destination == other.getSource());
		}
		return false;
	}
	
	@Override
	public Class<?> getElementType() {
		return this.getClass();
	}

	@Override
	public int compareTo(NsTracingEvent o) {
		if(o.equals(this)) {
			return 0;
		}
		return type.compareTo(o.getType());
	}
}
